package c.e.a.b.f.b;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application.ActivityLifecycleCallbacks;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
import c.e.a.b.b.j.c;
import com.huawei.hms.jos.games.ranking.RankingConst;
import java.util.Objects;

@TargetApi(14)
/* compiled from: com.google.android.gms:play-services-measurement-impl@@18.0.0 */
public final class y6 implements ActivityLifecycleCallbacks {
    public final /* synthetic */ c6 a;

    public y6(c6 c6Var, d6 d6Var) {
        this.a = c6Var;
    }

    public final void onActivityCreated(Activity activity, Bundle bundle) {
        try {
            this.a.d().n.a("onActivityCreated");
            Intent intent = activity.getIntent();
            if (intent != null) {
                Uri data = intent.getData();
                if (data != null) {
                    if (data.isHierarchical()) {
                        this.a.k();
                        this.a.a().v(new c7(this, bundle == null, data, t9.V(intent) ? "gs" : "auto", data.getQueryParameter("referrer")));
                        this.a.q().y(activity, bundle);
                        return;
                    }
                }
                this.a.q().y(activity, bundle);
            }
        } catch (Exception e) {
            this.a.d().f.b("Throwable caught in onActivityCreated", e);
        } finally {
            this.a.q().y(activity, bundle);
        }
    }

    public final void onActivityDestroyed(Activity activity) {
        h7 q = this.a.q();
        synchronized (q.l) {
            if (activity == q.g) {
                q.g = null;
            }
        }
        if (q.a.g.z().booleanValue()) {
            q.f.remove(activity);
        }
    }

    public final void onActivityPaused(Activity activity) {
        h7 q = this.a.q();
        if (q.a.g.o(p.v0)) {
            synchronized (q.l) {
                q.k = false;
                q.h = true;
            }
        }
        Objects.requireNonNull((c) q.a.n);
        long elapsedRealtime = SystemClock.elapsedRealtime();
        if (!q.a.g.o(p.u0) || q.a.g.z().booleanValue()) {
            i7 E = q.E(activity);
            q.d = q.c;
            q.c = null;
            q.a().v(new o7(q, E, elapsedRealtime));
        } else {
            q.c = null;
            q.a().v(new l7(q, elapsedRealtime));
        }
        w8 s = this.a.s();
        Objects.requireNonNull((c) s.a.n);
        s.a().v(new y8(s, SystemClock.elapsedRealtime()));
    }

    public final void onActivityResumed(Activity activity) {
        w8 s = this.a.s();
        Objects.requireNonNull((c) s.a.n);
        s.a().v(new v8(s, SystemClock.elapsedRealtime()));
        h7 q = this.a.q();
        if (q.a.g.o(p.v0)) {
            synchronized (q.l) {
                q.k = true;
                if (activity != q.g) {
                    synchronized (q.l) {
                        q.g = activity;
                        q.h = false;
                    }
                    if (q.a.g.o(p.u0) && q.a.g.z().booleanValue()) {
                        q.i = null;
                        q.a().v(new n7(q));
                    }
                }
            }
        }
        if (!q.a.g.o(p.u0) || q.a.g.z().booleanValue()) {
            q.z(activity, q.E(activity), false);
            a m = q.m();
            Objects.requireNonNull((c) m.a.n);
            m.a().v(new a3(m, SystemClock.elapsedRealtime()));
            return;
        }
        q.c = q.i;
        q.a().v(new m7(q));
    }

    public final void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
        h7 q = this.a.q();
        if (q.a.g.z().booleanValue() && bundle != null) {
            i7 i7Var = (i7) q.f.get(activity);
            if (i7Var != null) {
                Bundle bundle2 = new Bundle();
                bundle2.putLong("id", i7Var.c);
                bundle2.putString(RankingConst.RANKING_JGW_NAME, i7Var.a);
                bundle2.putString("referrer_name", i7Var.b);
                bundle.putBundle("com.google.app_measurement.screen_service", bundle2);
            }
        }
    }

    public final void onActivityStarted(Activity activity) {
    }

    public final void onActivityStopped(Activity activity) {
    }
}
